<?php

use yii\db\Schema;
use yii\db\Migration;

class m160121_031241_add_opt_price_ctr_cpm_fields extends Migration
{
    public function up()
    {
        $this->addColumn('{{%opt_price}}', 'bid_type', "int(1) NOT NULL DEFAULT '2' COMMENT '出价方式， 1 固定出价， 2 cpc优化出价, 3 ctr优化出价' after solution_id");
        $this->addColumn('{{%opt_price}}', 'opt_ctr', "decimal(12,2) after opt_cpm");
        $this->alterColumn('{{%opt_price}}', 'opt_cpc', "decimal(12,2) after opt_cpm");
    }

    public function down()
    {
        $this->dropColumn('{{%opt_price}}', 'bid_type');
        return $this->dropColumn('{{%opt_price}}', 'opt_ctr');
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}
